package dv.network;

import java.util.HashMap;
import java.util.HashSet;

public class Device {
    private HashSet<Rule> rules;

    private String name;
    HashMap<String, Port> ports = new HashMap<>();

    public Device(String name) {
        this.name = name;
        this.rules = new HashSet<>();
    }

    public String getName() {
        return name;
    }

    public HashSet<Rule> getRules() {
        return rules;
    }

    public Port getPortByName(String name) {
        return this.ports.get(name);
    }

    public Port addPortByName(String name) {
        Port p = new Port(name, this);
        this.ports.put(name, p);
        return p;
    }

    public HashMap<String, Port> getPorts() {
        return ports;
    }

    public void addRule(Rule rule) {
        this.rules.add(rule);
    }

    @Override
    public String toString() {
        return "Device{" +
                "name='" + name + '\'' +
                '}';
    }
}
